package com.x.erp.dao;

import com.x.erp.thirdparty.CarMappingThirdparty;
import com.x.framework.dao.BaseDao;
import org.springframework.stereotype.Repository;

import java.util.ArrayList;
import java.util.List;

/**
 * 与第三方辆关系映射
 *
 */
@Repository
public class CarMappingThirdpartyDao extends BaseDao{
	
	private final static String selectCarMappingThirdpartyLisSql = "SELECT T1.* FROM ERP_CAR_MAPPING_THIRDPARTY T1 WHERE 1=1 ";
	
	public List<CarMappingThirdparty> selectCarMappingThirdpartyList(CarMappingThirdparty carMappingThirdparty) throws Exception{
		StringBuilder sb = new StringBuilder(selectCarMappingThirdpartyLisSql);
		List<Object> params = new ArrayList<Object>();
		if(this.isString(carMappingThirdparty.getCarId())){
			sb.append("AND T1.CAR_ID = ? ");
			params.add(carMappingThirdparty.getCarId());
		}
		if(this.isNotNull(carMappingThirdparty.getCarThirdpartyId())){
			sb.append("AND T1.CAR_THIRDPARTY_ID = ? ");
			params.add(carMappingThirdparty.getCarThirdpartyId());
		}
		if(this.isNotNull(carMappingThirdparty.getCarType())){
			sb.append("AND T1.CAR_TYPE = ? ");
			params.add(carMappingThirdparty.getCarType());
		}
		return this.queryForList(sb.toString(), CarMappingThirdparty.class, params);
	}

}
